[XENBUS] Another fix to the wait-for-device-connection code.
authorkfraser@dhcp93.uk.xensource.com <kfraser@dhcp93.uk.xensource.com>
Fri, 30 Jun 2006 17:14:57 +0000 (18:14 +0100)
committerkfraser@dhcp93.uk.xensource.com <kfraser@dhcp93.uk.xensource.com>
Fri, 30 Jun 2006 17:14:57 +0000 (18:14 +0100)
The new method for printing unconnected device status is arguably
cleaner and also does not screw up reference counts (previous code
called bus_find_device() with no put_device() on the result.
Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c

index 8b619c5988988c4fed0043c926b71915ee74061b..9b4679a27a5fff49d1142f2d8f606b956190f6f0 100644 (file)
@@ -1057,15 +1057,21 @@ static struct device *find_disconnected_device(struct device *start)
                               find_disconnected_device_);
 }
 
-static int find_driverless_device_(struct device *dev, void *data)
+static int print_device_status(struct device *dev, void *data)
 {
-       return !dev->driver;
-}
+       struct xenbus_device *xendev = to_xenbus_device(dev);
 
-static struct device *find_driverless_device(struct device *start)
-{
-       return bus_find_device(&xenbus_frontend.bus, start, NULL,
-                              find_driverless_device_);
+       if (!dev->driver) {
+               /* Information only: is this too noisy? */
+               printk(KERN_INFO "XENBUS: Device with no driver: %s\n",
+                      xendev->nodename);
+       } else if (xendev->state != XenbusStateConnected) {
+               printk(KERN_WARNING "XENBUS: Timeout connecting "
+                      "to device: %s (state %d)\n",
+                      xendev->nodename, xendev->state);
+       }
+
+       return 0;
 }
 
 /*
@@ -1086,7 +1092,6 @@ static int __init wait_for_devices(void)
 {
        unsigned long timeout = jiffies + 10*HZ;
        struct device *dev = NULL;
-       struct xenbus_device *xendev;
 
        if (!is_running_on_xen())
                return -ENODEV;
@@ -1098,22 +1103,8 @@ static int __init wait_for_devices(void)
                schedule_timeout_interruptible(HZ/10);
        }
 
-       /* List devices which have drivers but are not yet connected. */
-       while (dev != NULL) {
-               xendev = to_xenbus_device(dev);
-
-               printk(KERN_WARNING "XENBUS: Timeout connecting "
-                      "to device: %s\n", xendev->nodename);
-
-               dev = find_disconnected_device(dev);
-       }
-
-       /* List devices with no driver (this is not necessarily an error). */
-       while ((dev = find_driverless_device(dev)) != NULL) {
-               xendev = to_xenbus_device(dev);
-               printk(KERN_INFO "XENBUS: Device with no driver: %s\n",
-                      xendev->nodename);
-       }
+       bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL,
+                        print_device_status);
 
        return 0;
 }